﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ep_lecturer_edit.aspx.cs"
    Inherits="ePioneer_Center_ep_lecturer_edit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="Javascript/jquery-1.4.4.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="query_form_table">
            <tr>
                <th>
                    讲师姓名
                </th>
                <td>
                    <asp:TextBox ID="txt_Lecturer" runat="server" Width="432px" />
                </td>
            </tr>
            <tr>
                <th>
                    所在地
                </th>
                <td>
                    <asp:DropDownList ID="ddl_Location" runat="server" Width="432px">
                        <asp:ListItem Value="" Text="请选择"></asp:ListItem>
                        <asp:ListItem Value="北京" Text="北京"></asp:ListItem>
                        <asp:ListItem Value="大连" Text="大连"></asp:ListItem>
                        <asp:ListItem Value="上海" Text="上海"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    专长领域
                </th>
                <td>
                    <asp:TextBox ID="txt_Speciality" runat="server" Width="432px" />
                </td>
            </tr>
            <tr>
                <th>
                    讲师简介
                </th>
                <td>
                    <asp:TextBox ID="txt_BriefInfo" runat="server" Width="432px" Height="49px" TextMode="MultiLine" />
                </td>
            </tr>
            <tr>
                <th>
                    头像
                </th>
                <td>
                    <asp:Image ID="Image1" runat="server" />
                    <asp:FileUpload ID="flImg" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="BtnModify" runat="server" Text="保存" OnClick="BtnModify_Click" />
                    &nbsp;
                    <input type="button" value="返回" onclick="location.href='ep_lecturer.aspx'" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#BtnModify').click(function () {
                var txt_Lecturer = $.trim($("#txt_Lecturer").val());
                var txt_BriefInfo = $.trim($("#txt_BriefInfo").val());
                var txt_Speciality = $.trim($("#txt_Speciality").val());
                if (txt_Lecturer == "") {
                    $("#txt_Lecturer").val("");
                    $("#txt_Lecturer").focus();
                    return false;
                }
                else {
                    if (getByteLen(txt_Lecturer) > 10) {
                        alert("讲师姓名不能超过5个中文字符");
                        $("#txt_Lecturer").focus();
                        return false;
                    }
                }
                if (getByteLen(txt_BriefInfo) > 150) {
                    alert("讲师简介不能超过75个中文字符");
                    $("#txt_BriefInfo").focus();
                    return false;
                }

                if (getByteLen(txt_Speciality) > 20) {
                    alert("专长领域不能超过10个中文字符");
                    $("#txt_Speciality").focus();
                    return false;
                }

                var filename = $('#flImg');
                if (filename.val() != "") {
                    var dotArray = filename.val().split(".");
                    if (dotArray.length < 2) {
                        alert("您上传的不是图片文件，请重新上传！");
                        return false;
                    }
                    else {
                        var FileExt;
                        FileExt = dotArray[dotArray.length - 1];
                        if (FileExt == "jpg" || FileExt == "jpeg" || FileExt == "gif" || FileExt == "png") {
                            return true;
                        }
                        else {
                            alert("您上传的不是图片文件或flash文件，请重新上传！");
                            return false;
                        }
                    }
                }
            });
        });
        function getByteLen(str) {
            var l = str.length;
            var n = l;
            for (var i = 0; i < l; i++) {
                if (str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255) {
                    n++;
                }
            }
            return n;
        } 
    </script>
    </form>
</body>
</html>
